package com.write.program.util;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Endstart
 * Date: 2020-04-26
 * Time: 0:35
 */
public class TestMain {

    public static void main(String[] args) {
//        int count = jerry(6, 100);
//        System.out.println(count);
        System.out.println(tom(10));
    }

    public static int jerry(int x, int m) {
        int a = 10; // #D1 refers to PrintLinkList number from your student number
        int sum;
        if (m <= 1)
            sum = x;
        else
            sum = 3 + jerry(x, m / a);
        return (sum);
    }

    public static int tom(int n) {
        int a = 10;
        int i, j, sum = 0;
        for (i = 1, j = 1; i <= n; i *= a, j++)
            sum = sum + jerry(j * j, n);
        return (sum);
    }
}
